package com.hippoDocker.streamrabbitmq.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @ClassName ReceiveMessageController
 * @Description TODO 接收消息
 * @Author hippoDocker
 * @Date 2022/7/6 10:01
 **/
@Component
@EnableBinding(Sink.class)
@Slf4j
public class ReceiveMessageListenerController {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message){
      log.info("消费者1号，=========>>接受到消息"+message.getPayload()+"\theaders:"+message.getHeaders().get("partitionKey")+"\tserverPort:"+serverPort);
    }
}
